Skip to content

feat(tab): modular ionic migration and lazy-load specs#31115

Open
thetaPC wants to merge 4 commits into
ionic-modularfrom
FW-6906
Open

feat(tab): modular ionic migration and lazy-load specs#31115
thetaPC wants to merge 4 commits into
ionic-modularfrom
FW-6906

Conversation

@thetaPC
Copy link
Copy Markdown
Contributor

@thetaPC thetaPC commented May 5, 2026

Issue number: resolves internal


What is the current behavior?

ion-tab retains a @virtualProp theme JSDoc annotation that is no longer appropriate after the Modular Ionic migration. Also no spec tests exist for the component's lazy-load behavior.

What is the new behavior?

  • Removes the @virtualProp theme from ion-tab
  • Adds spec tests for the lazy-load guard: verifies attachComponent is only called once across multiple setActive() calls, and documents the permanent-failure behavior when the delegate rejects on the first attempt

Does this introduce a breaking change?

  • Yes
  • No

Other information

Since I was already here, I added spec tests that would be beneficial.

Previews

@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment May 11, 2026 10:29pm

Request Review

@github-actions github-actions Bot added package: core @ionic/core package package: angular @ionic/angular package labels May 5, 2026
@thetaPC thetaPC changed the title feat(tab): modular ionic migration and lazy-load specsx feat(tab): modular ionic migration and lazy-load specs May 5, 2026
@thetaPC thetaPC marked this pull request as ready for review May 6, 2026 22:15
@thetaPC thetaPC requested a review from a team as a code owner May 6, 2026 22:15
@thetaPC thetaPC requested review from ShaneK and brandyscarney May 6, 2026 22:15
Copy link
Copy Markdown
Member

@ShaneK ShaneK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just highlighting an issue with a test that I think could be improved

Comment on lines +27 to +44

it('should not retry attach after a failed first attempt', async () => {
const page = await newSpecPage({
components: [Tab],
html: '<ion-tab tab="home" component="ion-content"></ion-tab>',
});

const tabEl = page.body.querySelector('ion-tab') as any;
const attachViewToDom = jest.fn().mockRejectedValue(new Error('attach failed'));
tabEl.delegate = mockDelegate(attachViewToDom);

// First call rejects because the delegate throws. The loaded flag is already
// set to true before the attempt, so the failure is permanent.
await expect(tabEl.setActive()).rejects.toThrow('attach failed');
await tabEl.setActive();

expect(attachViewToDom).toHaveBeenCalledTimes(1);
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "permanent failure" behavior actually what we want here, or just what the code currently does? The synchronous try/catch in prepareLazyLoaded can't catch the async rejection from attachComponent, and this.loaded = true is set before the await, so any first-attempt failure locks the tab out for good. A passing test on this makes a future fix (resetting loaded on rejection, or moving the catch around an await) look like a regression. Worth either filing a follow-up and referencing it here, or renaming the test so it reads "documents current behavior" rather than "asserts a contract"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added TODOs to go back and fix this on a separate ticket: 575d355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants